import { FormProps, FormSchema } from '/@/components/Table';
import { BasicColumn } from '/@/components/Table/src/types/table';
import { Pczt } from '/@/components/Pczt/index';
import { defineComponent, h } from 'vue';
import { PicBoolean } from '/@/components/PicBoolean/index';
import { FullSrcPic } from '/@/components/FullSrcPic/index';
import { DescItem } from '/@/components/Description';

export function tablePopupSchema() {
  return [
    {
      label: '行政村名称',
      field: 'villageName',
    },
    {
      label: '行政村归属',
      field: 'villageOwnership',
    },
  ];
}

export function getBasicColumns(): BasicColumn[] {
  return [
    {
      title: '排查状态',
      dataIndex: 'pczt',
      customRender: ({ value }) => {
        return h(Pczt, {
          pcztVal: value,
        });
      },
      width: '15em',
    },
    {
      title: '行政村归属',
      dataIndex: 'villageOwnership',
      width: '15em',
    },
    {
      title: '区县',
      dataIndex: 'xzqdmname',
      width: '15em',
    },
    {
      title: '街道',
      dataIndex: 'townname',
      width: '15em',
    },
    {
      title: '行政村名称',
      dataIndex: 'villageName',
      width: '15em',
    },
    {
      title: '村域内的电动自行车数量（辆）',
      dataIndex: 'electricBicycleNumber',
      width: '20em',
    },
    // {
    //   title: '生产经营租住村（居）民自建房集中连片区域（个）',
    //   dataIndex: 'selfBuiltHousesAreaNumber',
    //   width: '25em',
    // },
    {
      title: '村域内村民自建出租房的建筑数（栋）',
      dataIndex: 'selfBuiltRentalHouseNumber',
      width: '20em',
    },
    {
      title: '消防车道数量',
      dataIndex: 'fireLanesNumber',
      width: '15em',
    },
    {
      title: '消防水池数量',
      dataIndex: 'firePoolNumber',
      width: '15em',
    },
    {
      title: '室外消火栓数量',
      dataIndex: 'outdoorFireHydrantNumber',
      width: '15em',
    },
    {
      title: '消防水鹤数量',
      dataIndex: 'fireWaterCraneNumber',
      width: '15em',
    },
    // {
    //   title: '消防水鹤数量',
    //   dataIndex: 'fireWaterCraneNumber',
    //   width: '15em',
    // },
    {
      title: '电动自行车充电设施数量',
      dataIndex: 'chargingFacilitiesNumber',
      width: '15em',
    },
    {
      title: '专职消防队数量',
      dataIndex: 'fireBrigadeNumber',
      width: '15em',
    },
    {
      title: '专职消防队员数量',
      dataIndex: 'fireFighterNumber',
      width: '15em',
    },
    {
      title: '水罐消防车数量',
      dataIndex: 'fireTruckNumber',
      width: '15em',
    },
    {
      title: '微型消防站数量',
      dataIndex: 'fireStationNumber',
      width: '15em',
    },
    {
      title: '微型消防站队员数量',
      dataIndex: 'fireStationPersonnelNumber',
      width: '15em',
    },
    {
      title: '微型消防站消防车数量',
      dataIndex: 'fireStationTruckNumber',
      width: '15em',
    },
    {
      title: '照片',
      dataIndex: 'fireLayoutPhotos',
      width: '15em',
      customRender: ({ value }) => {
        return h(FullSrcPic, {
          boolVal: false,
          picList: value,
        });
      },
    },
    {
      title: '星级评判报告',
      dataIndex: 'star_rating_reports',
      width: '15em',
      customRender: ({ value }) => {
        return h(FullSrcPic, {
          boolVal: false,
          picList: value,
        });
      },
    },
  ];
}

export function getBasicShortColumns(): BasicColumn[] {
  return [
    {
      title: 'ID',
      width: 150,
      dataIndex: 'id',
      sorter: true,
      sortOrder: 'ascend',
    },
    {
      title: '所属工程',
      dataIndex: 'project',
      width: 120,
    },
    {
      title: '地理国情分类代码',
      dataIndex: 'cc',
      width: 80,
    },
  ];
}

export function getMultipleHeaderColumns(): BasicColumn[] {
  return [
    {
      title: 'ID',
      dataIndex: 'id',
      width: 200,
    },
    {
      title: '所属工程',
      dataIndex: 'project',
      width: 120,
    },
  ];
}

export function getCustomHeaderColumns(): BasicColumn[] {
  return [
    {
      title: 'ID',
      dataIndex: 'id',
      width: 200,
    },
    {
      // title: '姓名',
      dataIndex: 'project',
      width: 120,
      slots: { title: 'customTitle' },
    },
    {
      title: '地理国情分类代码',
      dataIndex: 'cc',
      width: 120,
    },
    {
      title: '创建时间',
      dataIndex: 'createOn',
      width: 120,
    },
    {
      title: '修改时间',
      dataIndex: 'modifiedOn',
      width: 120,
    },
  ];
}
const renderContent = ({ text, index }: { text: any; index: number }) => {
  const obj: any = {
    children: text,
    attrs: {},
  };
  if (index === 9) {
    obj.attrs.colSpan = 0;
  }
  return obj;
};
export function getMergeHeaderColumns(): BasicColumn[] {
  return [
    {
      title: 'ID',
      dataIndex: 'id',
      width: 300,
      customRender: renderContent,
    },
    {
      title: '所属工程',
      dataIndex: 'project',
      width: 300,
      customRender: renderContent,
    },
    {
      title: '地理国情分类代码',
      dataIndex: 'cc',
      colSpan: 0,
      customRender: renderContent,
    },
    {
      title: '创建时间',
      dataIndex: 'createOn',
      width: 200,
      customRender: renderContent,
    },
    {
      title: '修改时间',
      dataIndex: 'modifiedOn',
      width: 200,
      customRender: renderContent,
    },
  ];
}
export const getAdvanceSchema = (itemNumber = 6): FormSchema[] => {
  const arr: any = [];
  for (let index = 0; index < itemNumber; index++) {
    arr.push({
      field: `field${index}`,
      label: `字段${index}`,
      component: 'Input',
      colProps: {
        xl: 12,
        xxl: 8,
      },
    });
  }
  return arr;
};
export function getFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 100,
    schemas: [
      ...getAdvanceSchema(5),
      {
        field: `field11`,
        label: `Slot示例`,
        component: 'Select',
        slot: 'custom',
        colProps: {
          xl: 12,
          xxl: 8,
        },
      },
    ],
  };
}
export function getBasicData() {
  const data: any = (() => {
    const arr: any = [];
    for (let index = 0; index < 40; index++) {
      arr.push({
        id: `${index}`,
        name: 'John Brown',
        age: `1${index}`,
        no: `${index + 10}`,
        address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
        beginTime: new Date().toLocaleString(),
        endTime: new Date().toLocaleString(),
      });
    }
    return arr;
  })();
  return data;
}

export function getTreeTableData() {
  const data: any = (() => {
    const arr: any = [];
    for (let index = 0; index < 40; index++) {
      arr.push({
        id: `${index}`,
        name: 'John Brown',
        age: `1${index}`,
        no: `${index + 10}`,
        address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
        beginTime: new Date().toLocaleString(),
        endTime: new Date().toLocaleString(),
        children: [
          {
            id: `l2-${index}`,
            name: 'John Brown',
            age: `1${index}`,
            no: `${index + 10}`,
            address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
            beginTime: new Date().toLocaleString(),
            endTime: new Date().toLocaleString(),
          },
        ],
      });
    }
    return arr;
  })();

  return data;
}

export function getApkDetailColumns(): DescItem[] {
  return [
    {
      label: '状态',
      field: 'status',
    },
    {
      label: '名称',
      field: 'info.appName',
    },
    {
      label: '版本',
      field: 'info.appVersion',
    },
    {
      label: '版本ID',
      field: 'info.versionId',
    },
    {
      label: '签名',
      field: 'info.signature',
    },
    {
      label: '更新日志',
      field: 'info.changelog',
    },
    {
      label: '更新时间',
      field: 'info.uploadTime',
    },
  ];
}
